package com.ruoyi.web.controller.books;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.books.domain.BooksMakeVideo;
import com.ruoyi.books.service.IBooksMakeVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 非遗制作流程视频Controller
 *
 * @author ruoyi
 * @date 2024-03-28
 */
@Anonymous
@RestController
@RequestMapping("/books/makeVideo")
public class BooksMakeVideoController extends BaseController
{
    @Autowired
    private IBooksMakeVideoService booksMakeVideoService;

    /**
     * 查询非遗制作流程视频列表
     */
//    @PreAuthorize("@ss.hasPermi('books:makeVideo:list')")
    @GetMapping("/list")
    public TableDataInfo list(BooksMakeVideo booksMakeVideo)
    {
        startPage();
        List<BooksMakeVideo> list = booksMakeVideoService.selectBooksMakeVideoList(booksMakeVideo);
        return getDataTable(list);
    }

    /**
     * 导出非遗制作流程视频列表
     */
//    @PreAuthorize("@ss.hasPermi('books:makeVideo:export')")
    @Log(title = "非遗制作流程视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BooksMakeVideo booksMakeVideo)
    {
        List<BooksMakeVideo> list = booksMakeVideoService.selectBooksMakeVideoList(booksMakeVideo);
        ExcelUtil<BooksMakeVideo> util = new ExcelUtil<BooksMakeVideo>(BooksMakeVideo.class);
        util.exportExcel(response, list, "非遗制作流程视频数据");
    }

    /**
     * 获取非遗制作流程视频详细信息
     */
//    @PreAuthorize("@ss.hasPermi('books:makeVideo:query')")
    @GetMapping(value = "/{makeVideoId}")
    public AjaxResult getInfo(@PathVariable("makeVideoId") Long makeVideoId)
    {
        return success(booksMakeVideoService.selectBooksMakeVideoByMakeVideoId(makeVideoId));
    }

    /**
     * 新增非遗制作流程视频
     */
//    @PreAuthorize("@ss.hasPermi('books:makeVideo:add')")
    @Log(title = "非遗制作流程视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BooksMakeVideo booksMakeVideo)
    {
        return toAjax(booksMakeVideoService.insertBooksMakeVideo(booksMakeVideo));
    }

    /**
     * 修改非遗制作流程视频
     */
//    @PreAuthorize("@ss.hasPermi('books:makeVideo:edit')")
    @Log(title = "非遗制作流程视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BooksMakeVideo booksMakeVideo)
    {
        return toAjax(booksMakeVideoService.updateBooksMakeVideo(booksMakeVideo));
    }

    /**
     * 删除非遗制作流程视频
     */
//    @PreAuthorize("@ss.hasPermi('books:makeVideo:remove')")
    @Log(title = "非遗制作流程视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{makeVideoIds}")
    public AjaxResult remove(@PathVariable Long[] makeVideoIds)
    {
        return toAjax(booksMakeVideoService.deleteBooksMakeVideoByMakeVideoIds(makeVideoIds));
    }
}
